using Microsoft.EntityFrameworkCore;
using Vecen.BangChuang.Web;
using System.IO;
using System.Reflection;
using Abp.Reflection.Extensions;

namespace Vecen.BangChuang.EntityFrameworkCore
{
    public static class BangChuangDbContextConfigurer
    {
        public static void Configure(DbContextOptionsBuilder<BangChuangDbContext> builder, string connectionString)
        {
            var path = "";
            #if DEBUG
            path = WebContentDirectoryFinder.CalculateContentRootFolder();
            #else
            path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            #endif
            var dataSource = "Data Source=";
            connectionString = dataSource + path +"/"+ connectionString;
            builder.UseSqlite(connectionString);
        }
    }
}